Skip to content

feat: Add v3 LightGBM solar forecast model with enhanced feature engineering - #341

Open
Raakshass wants to merge 6 commits into
openclimatefix:mainfrom
Raakshass:feature/v3-lightgbm-model
Open

feat: Add v3 LightGBM solar forecast model with enhanced feature engineering#341
Raakshass wants to merge 6 commits into
openclimatefix:mainfrom
Raakshass:feature/v3-lightgbm-model

Conversation

@Raakshass

Copy link
Copy Markdown
Contributor

Pull Request

Description

This PR introduces a v3 LightGBM-based solar power prediction model with enhanced feature engineering, addressing the New Model Challenge (Issue #30).

Why LightGBM?

  • Faster training than XGBoost for large datasets
  • Better categorical handling with native support
  • Leaf-wise tree growth for improved accuracy
  • Lower memory usage during training

New Files

File Description
quartz_solar_forecast/forecasts/v3_lightgbm.py LightGBMSolarPredictor class
scripts/train_v3_model.py Training script with data loading and evaluation
quartz_solar_forecast/models/model-v3.0.pkl Pre-trained model (299KB)

Feature Engineering Improvements

1. Cyclical Time Encoding

Handles time discontinuities properly (no more 23→0 hour jumps):

hour_sin = np.sin(2 * np.pi * hour / 24)
hour_cos = np.cos(2 * np.pi * hour / 24)
day_sin = np.sin(2 * np.pi * day_of_year / 365)
day_cos = np.cos(2 * np.pi * day_of_year / 365)

2. Panel Features

  • orientation_sin/orientation_cos - Handles 0°/360° wrap-around
  • tilt_factor - Effective area calculation based on panel tilt

3. Weather Features

  • Temperature, cloud cover (low/mid/high layers)
  • Direct normal and diffuse radiation
  • Wind speed and precipitation

Training Script Usage

# Install dependency
pip install lightgbm

# Train with sampling (fast development)
python scripts/train_v3_model.py --sample-sites 20 --sample-days 7

# Full training (requires HuggingFace auth for uk_pv dataset)
huggingface-cli login
python scripts/train_v3_model.py --sample-sites 500 --sample-days 365

Initial Results (synthetic data)

  • MAE: ~0.23 kW
  • Normalized MAE: ~7.7%

Note: Final benchmarks against v1/v2 models will be added once trained on real HuggingFace data.

How Has This Been Tested?

  • Training script runs successfully
  • Model saves and loads correctly
  • Predictions output correct format

Addresses #30

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@Raakshass

Copy link
Copy Markdown
Contributor Author

CI Status Note

The lint-typecheck failures are caused by extra files that were inadvertently included in this commit. This will be addressed after the following dependent PRs are merged:

Plan: Once these PRs merge, I will:

  1. Rebase this branch on the updated main
  2. Create a clean commit with only the v3 model files
  3. Update this PR

Waiting for dependency merges before proceeding.

…neering

This PR introduces a new LightGBM-based solar power prediction model (v3) with
improvements over the existing XGBoost v2 model.

## New Files

- quartz_solar_forecast/forecasts/v3_lightgbm.py: LightGBMSolarPredictor class
- scripts/train_v3_model.py: Training script with data loading and evaluation
- quartz_solar_forecast/models/model-v3.0.pkl: Pre-trained model

## Feature Engineering Improvements

1. **Cyclical Time Encoding** - Handles time discontinuities properly:
   - hour_sin/hour_cos for time-of-day
   - day_sin/day_cos for day-of-year
   - month_sin/month_cos for seasonality

2. **Panel Features**:
   - Orientation sin/cos encoding (handles 0/360 wrap-around)
   - Tilt factor for effective area calculation

3. **Weather Features**:
   - Temperature, cloud cover (low/mid/high)
   - Direct normal and diffuse radiation
   - Wind speed and precipitation

## Why LightGBM?

- Faster training than XGBoost for large datasets
- Better handling of categorical features
- Leaf-wise tree growth for improved accuracy

Addresses openclimatefix#30
@Raakshass
Raakshass force-pushed the feature/v3-lightgbm-model branch from 8da06de to 40886a4 Compare February 16, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant